package day21;

/**
 * 题目：MP3光标位置
 * 题目链接：https://www.nowcoder.com/practice/eaf5b886bd6645dd9cfb5406f3753e15?tpId=37&&tqId=21287&rp=1&ru=/activity/oj&qru=/ta/huawei/question-ranking
 */

import java.io.*;

public class Main1 {
    public static void mouseMove(String numStr,String orderStr) {
        int n = Integer.parseInt(numStr);
        char[] chars = orderStr.toCharArray();
        int first = 1;
        int mouse = 1;
        if(n <= 4) {
            for (int i = 0; i < chars.length; i++) {
                if(mouse == 1 && chars[i] == 'U') {
                    mouse = n;
                } else if(mouse == n && chars[i] == 'D' ) {
                    mouse = 1;
                } else if(chars[i] == 'U') {
                    mouse--;
                } else if(chars[i] == 'D'){
                    mouse++;
                }
            }
            for (int i = 1; i < n; i++) {
                System.out.print(i+" ");
            }
            System.out.println(n);
            System.out.println(mouse);
        } else {
            for (int i = 0; i < chars.length; i++) {
                if(first == 1 && mouse == 1 && chars[i] == 'U') {
                    first = n-3;
                    mouse = n;
                } else if(first == n-3 && mouse == n && chars[i] == 'D') {
                    first = 1;
                    mouse = 1;
                } else if(first != 1 && mouse == first && chars[i] == 'U') {
                    first--;
                    mouse--;
                } else if((first != n-3) && mouse == first+3 && chars[i] == 'D') {   //first 不能用 ！=1 来判断
                    first++;
                    mouse++;
                } else if(chars[i] == 'D') {
                    mouse++;
                } else if(chars[i] == 'U') {
                    mouse--;
                }
            }
            for (int i = first; i < first+3 ; i++) {
                System.out.print(i+" ");
            }
            System.out.println(first+3);
            System.out.println(mouse);
        }
    }

    //部分代码跑不过找bug
    public static void main1(String[] args) {
        String numStr = "83";
        String orderStr = "UUDUDDDDUDUUDDDDUDD";
        mouseMove(numStr,orderStr);
        System.out.println("over");
    }

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String numStr;
        while ((numStr = reader.readLine()) != null ) {
            String orderStr = reader.readLine();
            mouseMove(numStr,orderStr);
        }
    }
}
